package com.hoyue.interact.service.impl;

import com.hoyue.common.utils.DateUtils;
import com.hoyue.interact.bean.Comment;
import com.hoyue.interact.bean.UserComment;
import com.hoyue.interact.dao.CommentMapper;
import com.hoyue.interact.dao.UserCommentMapper;
import com.hoyue.interact.service.CommentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class CommentServiceimpl implements CommentService {

     @Resource
     CommentMapper commentMapper;
     @Resource
    UserCommentMapper userCommentMapper;

    DateUtils dateUtils;


    @Override
    public List<Comment> listComment(Integer id) {
        return userCommentMapper.listComment(id);
    }

    @Override
    public Comment getComment(Integer id) {

        return commentMapper.getComment(id);
    }

    @Override
    public int addComment(UserComment userComment) {

        return userCommentMapper.addComment(userComment);
    }

    @Override
    public int insertComment(String content, Integer id, String userName, Integer matterId) {

        Date Atime = dateUtils.getDateTime();

        Comment comment=new Comment(content,Atime,userName);

        commentMapper.insertComment(comment);
        return comment.getId();
    }

    @Override
    public int delComment(int commentId) {
              UserComment userComment=new UserComment(null,null,commentId);
              userCommentMapper.movComment(userComment);
        return commentMapper.delComment(commentId);
    }

    @Override
    public int outComment(int userId, int matterId, int commmentId) {
        UserComment userComment=new UserComment(userId,matterId,commmentId);

        return userCommentMapper.movComment(userComment);
    }

    @Override
    public int movComment(UserComment userComment) {

        return userCommentMapper.movComment(userComment);
    }


}
